package cn.south.campus.admin.sys.controller;

import cn.south.campus.common.config.FileUploadConfig;
import cn.south.campus.common.file.service.FileUploadFactory;
import cn.south.campus.common.file.service.IFileService;
import cn.south.campus.common.file.vo.FileVO;
import cn.south.campus.common.model.bo.Result;
import cn.south.campus.common.model.enums.CommonEnums;
import cn.south.campus.common.utils.AssertUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2024/11/4 8:39
 */
@RestController
@RequestMapping("/file")
public class FileController {
    @PostMapping("upload")
    public Result<FileVO> upload(@RequestParam("file") MultipartFile file) {
        AssertUtils.isNotNull(file, CommonEnums.PARAMS_ERROR);
        IFileService fileService = FileUploadFactory.get(FileUploadConfig.UPLOAD_TYPE);
        FileVO fileVo = fileService.fileUpload(file,"");
        return Result.success(fileVo);
    }
}
